package sharping.appilog;

import java.lang.reflect.Type;
import java.util.ArrayList;

import sharping.appilog.ListItem.NoticeData;
import android.app.ExpandableListActivity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;

import com.android.volley.Request.Method;
import com.android.volley.Response.ErrorListener;
import com.android.volley.Response.Listener;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

public class Notice extends ExpandableListActivity {

	private static final String NOTICE_URL = app.HOST_URL + "rmobile/select_notice.php"; 
	private ArrayList<NoticeData> items;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}
	
	private StringRequest request = new StringRequest(Method.GET, NOTICE_URL, 
			new Listener<String>() {

				@Override
				public void onResponse(String result) {
					Gson gson = new Gson();
					Type notice_items = new TypeToken<ArrayList<NoticeData>>(){}.getType();
					items = gson.fromJson(result, notice_items);
					
					setListAdapter(new mAdapter());
				}
			}, new ErrorListener() {

				@Override
				public void onErrorResponse(VolleyError arg0) {
					// TODO Auto-generated method stub
					
				}
				
			});
	
	private class mAdapter extends BaseExpandableListAdapter {
		
		@Override
		public Object getChild(int arg0, int arg1) {
			
			return null;
		}

		@Override
		public long getChildId(int arg0, int arg1) {
			// TODO Auto-generated method stub
			return 0;
		}

		@Override
		public View getChildView(int arg0, int arg1, boolean arg2, View arg3,
				ViewGroup arg4) {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public int getChildrenCount(int arg0) {
			// TODO Auto-generated method stub
			return 1;
		}

		@Override
		public Object getGroup(int arg0) {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public int getGroupCount() {
			// TODO Auto-generated method stub
			return items.size();
		}

		@Override
		public long getGroupId(int arg0) {
			// TODO Auto-generated method stub
			return 0;
		}

		@Override
		public View getGroupView(int arg0, boolean arg1, View arg2,
				ViewGroup arg3) {
			
			
			
			return null;
		}

		@Override
		public boolean hasStableIds() {
			// TODO Auto-generated method stub
			return false;
		}

		@Override
		public boolean isChildSelectable(int arg0, int arg1) {
			// TODO Auto-generated method stub
			return false;
		}
		
	}
}
